/**
 * Creates a background gradient.
 *
 * @param {Color} $bg-color The background color of the gradient
 * @param {String/List} [$type] The type of gradient to be used. Can either
 * be a String which is a predefined gradient, or it can can be a list of
 * color_stops. If none is set, it will still set the `background-color`
 * to the $background-color.
 * @param {String} [$direction=top] The direction of the gradient. Can either be
 * `top` or `left`.
 * @member Global_CSS
 */
@mixin background-gradient($bg-color, $type: $base-gradient, $direction: top) {
  background-image: none;
  background-color: $bg-color;

  @if $base-gradient != null and $bg-color != transparent {
    //color_stops
    @if type-of($type) == "list" {
      @include background-image(linear-gradient($direction, $type));
    }

      //default gradients
    @else if $type == bevel {
      @include background-image(linear-gradient($direction, color_stops(
                      lighten($bg-color, 15%),
                      lighten($bg-color, 8%) 30%,
                      $bg-color 65%,
                      darken($bg-color, 6%)
      )));
    } @else if $type == glossy {
      @include background-image(linear-gradient($direction, color_stops(lighten($bg-color, 15%), lighten($bg-color, 5%) 50%, $bg-color 51%, darken($bg-color, 5%))));
    } @else if $type == recessed {
      @include background-image(linear-gradient($direction, color_stops(darken($bg-color, 10%), darken($bg-color, 5%) 10%, $bg-color 65%, lighten($bg-color, .5%))));
    } @else if $type == matte {
      @include background-image(linear-gradient($direction, color_stops(lighten($bg-color, 3%), darken($bg-color, 4%))));
    } @else if $type == matte-reverse {
      @include background-image(linear-gradient($direction, color_stops(darken($bg-color, 6%), lighten($bg-color, 4%))));
    } @else if $type == glossy-toolbar {
      @include background-image(linear-gradient($direction, color_stops(#F0F5FA, #DAE6F4 2%, #CEDDEF)));
    }

      //ext3.3 gradients
    @else if $type == panel-header {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: -0.857deg, $saturation: -1.63%, $lightness: 3.529%),
                      adjust-color($bg-color, $hue: 0.158deg, $saturation: -1.21%, $lightness: 0.392%) 45%,
                      adjust-color($bg-color, $hue: 1.154deg, $saturation: 0.607%, $lightness: -7.647%) 46%,
                      adjust-color($bg-color, $hue: 1.154deg, $saturation: 0.607%, $lightness: -7.647%) 50%,
                      adjust-color($bg-color, $hue: 1.444deg, $saturation: -1.136%, $lightness: -4.706%) 51%,
                      $bg-color
      )));
    } @else if $type == tabbar {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: 0.0deg, $saturation: 1.604%, $lightness: 4.706%),
                      $bg-color
      )));
    } @else if $type == tab {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: 1.382deg, $saturation: -18.571%, $lightness: -4.902%),
                      adjust-color($bg-color, $hue: 0.43deg, $saturation: -10.311%, $lightness: -2.157%) 25%,
                      $bg-color 45%
      )));
    } @else if $type == tab-active {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: -212.903deg, $saturation: -88.571%, $lightness: 6.863%),
                      adjust-color($bg-color, $hue: 0.43deg, $saturation: -6.753%, $lightness: 4.706%) 25%,
                      $bg-color 45%
      )));
    } @else if $type == tab-over {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: 4.462deg, $saturation: -9.524%, $lightness: -3.725%),
                      adjust-color($bg-color, $hue: 2.272deg, $saturation: 0.0%, $lightness: -1.569%) 25%,
                      $bg-color 45%
      )));
    } @else if $type == tab-disabled {
      @include background-image(linear-gradient($direction, color_stops(
                      $bg-color,
                      adjust-color($bg-color, $hue: -0.267deg, $saturation: 18.571%, $lightness: 2.941%)
      )));
    } @else if $type == grid-header {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: 20.392%),
                      adjust-color($bg-color, $hue: 220.0deg, $saturation: 5.66%, $lightness: 12.353%)
      )));
    } @else if $type == grid-header-over {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: 0.175deg, $saturation: 0.967%, $lightness: 14.118%),
                      adjust-color($bg-color, $hue: 0.175deg, $saturation: 0.967%, $lightness: 14.118%) 39%,
                      adjust-color($bg-color, $hue: 0.372deg, $saturation: 0.101%, $lightness: 10.196%) 40%,
                      adjust-color($bg-color, $hue: 0.372deg, $saturation: 0.101%, $lightness: 10.196%)
      )));
    } @else if $type == grid-row-over {
      @include background-image(linear-gradient($direction, color_stops(
                      adjust-color($bg-color, $hue: 0.175deg, $saturation: 0.967%, $lightness: 14.118%),
                      $bg-color
      )));
    } @else if $type == grid-cell-special {
      @include background-image(linear-gradient(left, color_stops(
                      $bg-color,
                      darken($bg-color, 5)
      )));
    } @else if $type == glossy-button or $type == glossy-button-disabled {
      @include background-image(linear-gradient($direction, color_stops(
                      $bg-color,
                      adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: -2.353%) 48%,
                      adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: -11.373%) 52%,
                      adjust-color($bg-color, $hue: 0deg, $saturation: 0%, $lightness: -9.412%)
      )));
    } @else if $type == glossy-button-over {
      @include background-image(linear-gradient($direction, color_stops(
                      $bg-color,
                      adjust-color($bg-color, $hue: 1.754deg, $saturation: 0.0%, $lightness: -2.157%) 48%,
                      adjust-color($bg-color, $hue: 5.833deg, $saturation: -35.135%, $lightness: -9.216%) 52%,
                      adjust-color($bg-color, $hue: 5.833deg, $saturation: -27.273%, $lightness: -7.647%)
      )));
    } @else if $type == glossy-button-pressed {
      @include background-image(linear-gradient($direction, color_stops(
                      $bg-color,
                      adjust-color($bg-color, $hue: -1.839deg, $saturation: -2.18%, $lightness: 2.157%) 48%,
                      adjust-color($bg-color, $hue: -2.032deg, $saturation: 37.871%, $lightness: -4.706%) 52%,
                      adjust-color($bg-color, $hue: -1.641deg, $saturation: 36.301%, $lightness: -2.549%)
      )));
    }
  }
}